import {observable, action} from 'mobx'
import { WeaTools } from 'ecCom';
import {WeaTableNew} from 'comsMobx'
const {TableStore} = WeaTableNew
import * as mobx from 'mobx'
import * as API_LIST from '../../apis/chart/fnaExpenseCommon'

/**
 * 流程列表页面公共Store
 */
export class FnaExpenseCommonListStore {

	constructor(){
	}
	
	/** 列表store */
    @observable title = "公共";
    @observable dataKey = "";
    @observable tableStore = new TableStore();

    //列表数据
    initDataList = (value) => {
        let params = {
            chartType:value.seriesType,
            orgIds:value.orgIds,
            year:value.year,
        };

        if(value.seriesType == 'bar'){
            params = Object.assign(params,{month:value.month});
        } else if(value.seriesType == 'pie') {
            params = Object.assign(params,{subjectId:value.subjectId});
        }

        let pageType = value.pageType;
        //人力资源
        if(pageType == "FnaResourceExpense"){
            API_LIST.resourceExpenseChart(params).then(data =>{
                this.tableStore.getDatas(data.datas);
                this.dataKey = data.datas;
            });
        } else if(pageType == "FnaDepartmentExpense"){//部门费用
            API_LIST.departmentExpenseChart(params).then(data =>{
                this.tableStore.getDatas(data.datas);
                this.dataKey = data.datas;
            });
        } else if(pageType == "FnaSubCompanyExpense"){//分部费用
            API_LIST.subCompanyExpenseChart(params).then(data =>{
                this.tableStore.getDatas(data.datas);
                this.dataKey = data.datas;
            });
        } else if(pageType == "FnaCostCenterExpense"){//成本中心费用
            API_LIST.costCenterExpenseChart(params).then(data =>{
                this.tableStore.getDatas(data.datas);
                this.dataKey = data.datas;
            });
        } else if(pageType == "FnaProjectExpense"){//项目费用
            API_LIST.projectExpenseChart(params).then(data =>{
                this.tableStore.getDatas(data.datas);
                this.dataKey = data.datas;
            });
        } else if(pageType == "FnaCompactExpense"){//合同费用
            API_LIST.compactExpense(params).then(data =>{
                this.tableStore.getDatas(data.datas);
                this.dataKey = data.datas;
            });
        } else if(pageType == "FnaCustomerExpense"){//客户费用
            API_LIST.customerExpenseChart(params).then(data =>{
                this.tableStore.getDatas(data.datas);
                this.dataKey = data.datas;
            });
        }
    }
}